; Disassembly of the file "Z:\home\knoppix\CoBra Project\Software\CPM\CPM CHRIS_INST analysis\Boot_Sector.bin"
; 
; CPU Type: Z80
; 
; Using the opcode map file "Z:\home\knoppix\CoBra Project\Software\CPM\CPM CHRIS_INST analysis\Boot_Sector.bin.opmap"
; ; Created with dZ80 2.0
; 
; on Thursday, 26 of January 2017 at 01:27 PM
; 

	ORG	$0000

	JR	START

	DEFB	$00
	DEFB	$80	; This will be left behind as I/O Byte
	DEFB	$00
	DEFB	$00
	DEFB	$00
	DEFB	$00
	DEFB	$00
	DEFB	$00
	DEFB	$00
	DEFB	$00
	DEFB	$00
	DEFB	$00
	DEFB	$00
	DEFB	$00

START:	DI
	LD	HL,$0100
	LD	SP,HL		; set stack at $0100
	LD	A,$92		; control word for 8255: Mode Set flag=active,
				; 			Group A: Select Mode 0,
				;				 Port A set to Input mode,
				;				 Port C (upper half) set to Output Mode,
				;			Group B: Select Mode 0,
				;				 Port B set to Input Mode,
				;				 Port C (lower half) set to Output Mode
	OUT	($DF),A		; write control word to 8255
	OUT	($DF),A		; write control word to 8255 (again !?)
	LD	A,$41
	OUT	($FE),A		; set 06 to "1" for VRAM access, border to blue
	LD	DE,$6200
	LD	BC,$1E00
	LDIR			; copy $0100-$1EFF to $6200-7FFF			BLOCK#1 ($6200-77FF) + CCP ($7800-$7FFF)
				; when done, HL=$1F00					##### CCP WILL BE COPIED TO $E000-$E7FF BY BIOS CTC INT. ROUTINE #2 #####
	LD	DE,$E800
	LD	BC,$1800
	LDIR			; copy $1F00-$36FF to $E800-$FFFF			(BDOS+BIOS)
					; when done, HL=$3700

			; ################### BIOS MODIFICATIONS ######################
	LD	A,$D9		; ----------- BIOS DPH area ------------
	LD	($FB00),A	; change XLT in DPH#0 in BIOS
	LD	($FB10),A	; change XLT in DPH#1 in BIOS
;	LD	($FB40),A	; change XLT in DPH#4 in BIOS
	LD	A,$CA
	LD	($FB0A),A	; change DPB in DPH#0 in BIOS
	LD	($FB1A),A	; change DPB in DPH#1 in BIOS
;	LD	($FB4A),A	; change DPB in DPH#4 in BIOS
;	LD	($F659),A	; change DPB addr stored parameter in BIOS
	LD	HL,$FDA0
	LD	($FB1C),HL	; change CSV in DPH#1 to $FDA0 (for DD it is double the size of SD, so we have to move CSV area somewhere else)
	LD	HL,$FE60
	LD	($FB1E),HL	; change ALV in DPH#1 to $FDC0 (for DD it is double the size of SD, so we have to move CSV area somewhere else)
				; ----------- BIOS SECTRAN fix for A:,B: to be 860K DSDD drives -----------
	LD	HL,$0000
	LD	($F80C),HL	; changes 2804="JR Z,$F812" to NOP NOP
				; ----------- BIOS BLOCK#1 fix for A:,B: to be the same as C:,D: ----------
	LD	($7035),HL	; changes 2808="JR Z,$703F" to NOP NOP
	LD	($6EA9),HL	; changes 2802="JR Z,$6EAD" to NOP NOP
	LD	($70AC),HL	; changes 2805="JR Z,$70B3" to NOP NOP
	LD	A,$18
	LD	($6EC3),A	; changes $20="JR NZ, ..." to "JR ..."
			; #############################################################

;	RES	6,A		; A=$01
	LD	A,$01		; A=$01
	OUT	($FE),A		; set 06 to "0" for DRAM access
	LD	HL,$3700
	LD	DE,$0100
	LD	BC,$0900
	LDIR			; copy $3700-$3FFF to $0100-$09FF			(CHRIS DEMO)
	LD	HL,$0AFF
	LD	DE,$0B00
	LD	BC,$DD06
	LDIR			; fill $0B00-$E805 with ($0AFF)=$1A
	JP	$F600		; jump to start of BIOS (BIOS function #0, BOOT)